﻿using Assets.Scripts.config;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YeqianFramework.common;
using UnityEngine;
using Assets.Scripts.Manager;

namespace Assets.Scripts
{
	/// <summary>
	/// 挂载在恒星上
	/// </summary>
	public class FixedStar : Star
	{
		public FixedStarData data;

		protected override void InitStarData()
		{
			try
			{
				data = TheThreeBodyGameManager.Current.FixedStarsDic[gameObject.name];
			}
			catch (KeyNotFoundException)
			{
				YQLogCenter.Current.LogError("这个游戏对象的名字 : " + gameObject.name + " 不在星体列表里面");
				StringBuilder builder = new StringBuilder();
				foreach (var item in TheThreeBodyGameManager.Current.FixedStarsDic.Keys)
				{
					builder.Append(item + "\r\n");
				}
				YQLogCenter.Current.LogError("星体列表包括：" + builder.ToString());
				gameObject.SetActive(false);
				return;
			}
			transform.position = data.Position;
			m_Rigidbody.mass = data.Mass;
			speed = data.AwakeSpeedFactor == 0 ? TheThreeBodyGameManager.Current.GameConfig.AwakeSpeedFactor : data.AwakeSpeedFactor;


			transform.localScale = Vector3.one * data.Scale;
		}
	}
}
